package com.ctshk.sapp.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.model.TokenUser;
import com.ctshk.rpc.system.dto.MainDataTourGroupCodeListDTO;
import com.ctshk.rpc.system.dto.MainDataTourGroupCodeQueryDTO;
import com.ctshk.rpc.system.dto.MainDataTourGroupDTO;
import com.ctshk.rpc.system.req.MainDataTourGroupCodeAddReq;
import com.ctshk.rpc.system.req.MainDataTourGroupCodeListReq;
import com.ctshk.rpc.system.req.MainDataTourGroupCodeUpdateReq;
import com.ctshk.rpc.system.req.MainDataTourGroupCodeUpdateStatusReq;
import com.ctshk.rpc.system.service.IMainDataTourGroupCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 旅游组别码表 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-30
 */
@Api(value = "主数据旅游组别码",tags = "主数据旅游组别码")
@RestController
@RequestMapping("/main/data/tour/group/code")
public class MainDataTourGroupCodeController extends BaseController {


    @DubboReference
    private IMainDataTourGroupCodeService iMainDataTourGroupCodeService;

    /**
     * 新增旅游组别
     */
    @ApiOperation(value = "新增旅游组别码", notes = "新增旅游组别码")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增旅游组别码", operDesc = "新增旅游组别码")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataTourGroupCodeAddReq req) {
        TokenUser currentUser = getCurrentUser(getRequest());
        req.setCreateId(currentUser.getId());
        req.setModifiedId(currentUser.getId());
        req.setModifiedName(currentUser.getUsername());
        return iMainDataTourGroupCodeService.add(req);
    }

    /**
     * 编辑旅游组别
     */
    @ApiOperation(value = "编辑旅游组别码", notes = "编辑旅游组别码")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑旅游组别码", operDesc = "编辑旅游组别码")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataTourGroupCodeUpdateReq req) {
        TokenUser currentUser = getCurrentUser(getRequest());
        req.setModifiedId(currentUser.getId());
        req.setModifiedName(currentUser.getUsername());
        return iMainDataTourGroupCodeService.update(req);
    }

    /**
     * 编辑旅游组别状态
     */
    @ApiOperation(value = "编辑旅游组别码状态", notes = "编辑旅游组别码状态")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑旅游组别码", operDesc = "编辑旅游组别码")
    @PostMapping("/updateStatus")
    public Result updateStatus(@RequestBody @Valid MainDataTourGroupCodeUpdateStatusReq req) {
        TokenUser currentUser = getCurrentUser(getRequest());
        req.setModifiedId(currentUser.getId());
        req.setModifiedName(currentUser.getUsername());
        return iMainDataTourGroupCodeService.updateStatus(req);
    }

    /**
     * 查看旅游组别码
     */
    @ApiOperation(value = "查看旅游组别码", notes = "查看旅游组别码")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看旅游组别码", operDesc = "查看旅游组别码")
    @PostMapping("/query")
    public Result<MainDataTourGroupCodeQueryDTO> query(@RequestBody @Valid MainDataTourGroupCodeUpdateStatusReq req) {
        return iMainDataTourGroupCodeService.query(req);
    }

    /**
     * 旅游组别列表
     */
    @ApiOperation(value = "旅游组别列表", notes = "旅游组别列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看旅游组别码", operDesc = "查看旅游组别码")
    @PostMapping("/list")
    public Result<PageResponse<MainDataTourGroupCodeListDTO>> query(@RequestBody @Valid MainDataTourGroupCodeListReq req) {
        return Result.success(iMainDataTourGroupCodeService.list(req));
    }

    /**
     * 旅行团首页目录三级分类一级菜单
     * @return
     */
    @ApiOperation(value = "旅行团首页目录三级分类一级菜单", notes = "旅行团首页目录三级分类一级菜单")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "旅行团首页目录三级分类一级菜单", operDesc = "旅行团首页目录三级分类一级菜单")
    @PostMapping("/query/home/catalog1")
    public List<MainDataTourGroupCodeQueryDTO> getCatalogGroup(){
        return iMainDataTourGroupCodeService.getMainDataTourGroupCode();
    }




}
